package com.kkwrite.regimen.common.constant;

/**
 * Created by lisha on 2018/7/16 11:27.
 *
 * @author lisha
 */
public enum LanguageEnum {
    /**
     * 简体中文
     */
    CHINESE_SIMPLIFIED("简体中文", 0),
    /**
     * 繁体中文
     */
    CHINESE_TRADITIONAL("繁体中文", 1),
    /**
     * 英语
     */
    ENGLISH("英语", 2)
    ;

    private String language;
    private Integer value;

    LanguageEnum(String language, Integer value) {
        this.language = language;
        this.value = value;
    }

    public String getLanguage() {
        return this.language;
    }

    public Integer getValue() {
        return this.value;
    }

    public static Integer findValue(String language) {
        if (language == null || language.isEmpty()) {
            return LanguageEnum.CHINESE_SIMPLIFIED.getValue();
        }
        for (LanguageEnum languageEnum : LanguageEnum.values()) {
            if (language.equals(languageEnum.getLanguage())) {
                return languageEnum.getValue();
            }
        }
        return LanguageEnum.CHINESE_SIMPLIFIED.getValue();
    }

    public static String findLanguageName(int value) {
        for (LanguageEnum anEnum : LanguageEnum.values()) {
            if (anEnum.getValue() == value) {
                return anEnum.getLanguage();
            }
        }
        return LanguageEnum.CHINESE_SIMPLIFIED.getLanguage();
    }

}
